<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>添加压缩机维修报表</title>
<script>
	function formatDate(v) {
		if (typeof v == 'string')
			v = parseDate(v);
		if (v instanceof Date) {
			var y = v.getFullYear();
			var m = v.getMonth() + 1;
			var d = v.getDate();
			var h = v.getHours();
			return y + '-' + m + '-' + d;
		}
		return '';
	}

	function markAsFinished(button, id) {
		document.getElementById(id).value = formatDate(new Date());
		button.disabled = true;
	}
</script>

<script>
	$(function() {
		$("#datepicker").datepicker({
			dateFormat : 'yy-mm-dd',
			beforeShow : function(input, inst) {
				inst.dpDiv.css({
					marginTop : -input.offsetHeight + 'px',
					marginLeft : input.offsetWidth + 5 + 'px'
				});
			}
		});
	});

	$(document).ready(function() {
		$("#inputForm").validate({
			rules: {
				scheduleFinish:"required",
				
			}
		});
	});
</script>
</head>

<body>
	<form:form id="inputForm" modelAttribute="report"
		action="${ctx}/report/comp/save/${report.id}" method="post">
		<input type="hidden" name="id" value="${report.id}" />
		<c:if test="${empty add}"><shiro:lacksPermission name="report:superedit">
		<input type="hidden" name="customerName" value="${report.customerName}" />
		<input type="hidden" name="assignedUser" value="${report.assignedUser}" />
		<input type="hidden" name="scheduleFinish" value="<bean:write format="yyyy-MM-dd" name="report" property="scheduleFinish"/>"/>
		</shiro:lacksPermission></c:if> 
		<input type="hidden" name="updatebypersion" value="wrwrw" />
		<fieldset class="prepend-top">
			<legend>添加压缩机维修报表</legend>
			<c:if test="${empty add}">
				<div>
					<label for="uid" class="field">维修ID:</label> <input
						disabled="disabled" type="text" id="uid" name="uid" size="40"
						value="${report.reportId}" />
				</div>
			</c:if>
			<div>
				<label for="keyComment" class="field">重点说明:</label> <input
					type="text" id="keyComment" name="keyComment" size="40"
					value="${report.keyComment}" />
			</div>
			<div>
				<label for="customerName" class="field">客户名称:<font color="red">*</font></label> <select
				<c:if test="${empty add}"><shiro:lacksPermission name="report:superedit">disabled="disabled"</shiro:lacksPermission></c:if>
					style="width: 300px" id="customerName" name="customerName" size="1">
					<c:forEach var="customer" items="${customers}">
						<option value="${customer.name}"
							<c:if test="${report.customerName == customer.name }">selected="selected"
						</c:if>>${customer.name}</option>
					</c:forEach>
				</select>
			</div>
			<div>
				<label for="SN" class="field">SN:</label> <input type="text" id="SN"
					name="SN" size="40" value="${report.SN}" />
			</div>
			<div>
				<label for="assignedUser" class="field">安排人员:<font color="red">*</font></label> 
				<select  <c:if test="${empty add}"><shiro:lacksPermission name="report:superedit">disabled="disabled"</shiro:lacksPermission></c:if> 
					style="width: 300px" id="assignedUser" name="assignedUser" size="1">
					<c:forEach var="user" items="${users}">
						<option value="${user.name}"
							<c:if test="${report.assignedUser == user.name }">selected="selected"
						</c:if>>${user.name}</option>
					</c:forEach>
				</select>
			</div>
			<div>
				<label for="scheduleFinish" class="field">预计完成时间:<font color="red">*</font></label> 
				<input <c:if test="${empty add}"><shiro:lacksPermission name="report:superedit">disabled="disabled"</shiro:lacksPermission></c:if>
					type="text" id="datepicker" name="scheduleFinish" size="40" 
					value="<bean:write format="yyyy-MM-dd" name="report" property="scheduleFinish"/>" />
				格式：yyyy-MM-dd
			</div>
			<div>
				<label for="maintanceNumber" class="field">维修单号:</label> <input
					type="text" id="maintanceNumber" name="maintanceNumber" size="40"
					value="${report.maintanceNumber}" />
			</div>
			<div>
				<label for="customerOrderNumber" class="field">客户订单号:<font color="red">*</font></label> <input
					type="text" id="customerOrderNumber" name="customerOrderNumber"
					size="40" value="${report.customerOrderNumber}" />
			</div>
			<div>
				<label for="inputRepository" class="field">入库:</label> <input
					readonly="readonly"
					type="text" id="inputRepository" name="inputRepository" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="inputRepository"/>" />
				<c:if test="${empty report.inputRepository}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'inputRepository')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="validation" class="field">检测:</label> <input
					readonly="readonly"
					type="text" id="validation" name="validation" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="validation"/>" />
				<c:if test="${empty report.validation}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'validation')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="tryRunning" class="field">试运行:</label> <input
					readonly="readonly"
					type="text" id="tryRunning" name="tryRunning" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="tryRunning"/>" />
				<c:if test="${empty report.tryRunning}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'tryRunning')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="leak" class="field">检漏:</label> <input
					readonly="readonly"
					type="text" id="leak" name="leak" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="leak"/>" />
				<c:if test="${empty report.leak}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'leak')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="test" class="field">测试:</label> <input
					readonly="readonly"
					type="text" id="test" name="test" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="test"/>" />
				<c:if test="${empty report.test}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'test')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="maintance" class="field">维修:</label> <input
					readonly="readonly"
					type="text" id="maintance" name="maintance" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="maintance"/>" />
				<c:if test="${empty report.maintance}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'maintance')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="mtest" class="field">再测试:</label> <input
					readonly="readonly"
					type="text" id="mtest" name="mtest" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="mtest"/>" />
				<c:if test="${empty report.mtest}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'mtest')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="finishPackage" class="field">完修包装:</label> <input
					readonly="readonly"
					type="text" id="finishPackage" name="finishPackage" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="finishPackage"/>" />
				<c:if test="${empty report.finishPackage}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'finishPackage')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="packages" class="field">装箱:</label> <input
					readonly="readonly"
					type="text" id="packages" name="packages" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="packages"/>" />
				<c:if test="${empty report.packages}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'packages')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="outputRepository" class="field">出库:</label> <input
					readonly="readonly"
					type="text" id="outputRepository" name="outputRepository" size="40"
					value="<bean:write format="yyyy-MM-dd" name="report" property="outputRepository"/>" />
				<c:if test="${empty report.outputRepository}">
					<input type="button" class="button"
						onclick="markAsFinished(this, 'outputRepository')" value="完成" />
				</c:if>
			</div>
			<div>
				<label for="comments" class="field">备注:</label> <input type="text"
					id="comments" name="comments" size="40" value="${report.comments}" />
			</div>
			<c:if test="${empty add}">
				<div>
					<label for="updateTime" class="field">更新时间:</label> <input
						disabled="disabled" type="text" id="updateTime" name="updateTime"
						size="40"
						value="<bean:write format="yyyy-MM-dd" name="report" property="updateTime"/>" />
				</div>
				<!-- <div>
					<label for="updateByPersion" class="field">更新人员:</label> <input
						disabled="disabled" type="text" id="updateByPersion"
						name="updateByPersion" size="40" value="${report.updateByPersion}" />
				</div> -->
			</c:if>
		</fieldset>
		<div>
			<c:if test="${report.status != 'finish'}"><input id="submit" class="button" type="submit" value="提交" />&nbsp; </c:if> 
			<input id="cancel" class="button" type="button" value="返回"
				onclick="history.back()" />
		</div>
	</form:form>
</body>
</html>
